package com.certapp.dao.mapper;

import com.certapp.dao.entity.TbFiledInfo;
import com.certapp.dao.entity.TbFiledInfoExample;
import java.util.List;
import java.util.Optional;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface TbFiledInfoMapper {

    @Select({"select",
            "id, cert_config_id, filed_serial, filed_name, filed_name_zh, filed_local, show_enable, ",
            "filed_demo", "from tb_filed_info",
            "where cert_config_id = #{certConfigId,jdbcType=INTEGER}"})
    @Results({@Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true),
            @Result(column = "cert_config_id", property = "certConfigId",
                    jdbcType = JdbcType.INTEGER),
            @Result(column = "filed_serial", property = "filedSerial", jdbcType = JdbcType.VARCHAR),
            @Result(column = "filed_name", property = "filedName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "filed_name_zh", property = "filedNameZh",
                    jdbcType = JdbcType.VARCHAR),
            @Result(column = "filed_local", property = "filedLocal", jdbcType = JdbcType.VARCHAR),
            @Result(column = "show_enable", property = "showEnable", jdbcType = JdbcType.INTEGER),
            @Result(column = "filed_demo", property = "filedDemo", jdbcType = JdbcType.VARCHAR)})
    List<TbFiledInfo> selectByCertConfigId(Integer certConfigId);

    @Delete({"delete from tb_filed_info",
            "where cert_config_id = #{certConfigId,jdbcType=INTEGER}"})
    int deleteByCertConfigId(Integer certConfigId);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table
     * tb_filed_info
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbFiledInfoSqlProvider.class, method = "countByExample")
    long countByExample(TbFiledInfoExample example);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table
     * tb_filed_info
     *
     * @mbg.generated
     */
    @DeleteProvider(type = TbFiledInfoSqlProvider.class, method = "deleteByExample")
    int deleteByExample(TbFiledInfoExample example);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table
     * tb_filed_info
     *
     * @mbg.generated
     */
    @Delete({"delete from tb_filed_info", "where id = #{id,jdbcType=INTEGER}"})
    int deleteByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table
     * tb_filed_info
     *
     * @mbg.generated
     */
    @Insert({"insert into tb_filed_info (cert_config_id, filed_serial, ",
            "filed_name, filed_name_zh, ", "filed_local, show_enable, ", "filed_demo)",
            "values (#{certConfigId,jdbcType=INTEGER}, #{filedSerial,jdbcType=VARCHAR}, ",
            "#{filedName,jdbcType=VARCHAR}, #{filedNameZh,jdbcType=VARCHAR}, ",
            "#{filedLocal,jdbcType=VARCHAR}, #{showEnable,jdbcType=INTEGER}, ",
            "#{filedDemo,jdbcType=VARCHAR})"})
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false,
            resultType = Integer.class)
    int insert(TbFiledInfo record);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table
     * tb_filed_info
     *
     * @mbg.generated
     */
    @InsertProvider(type = TbFiledInfoSqlProvider.class, method = "insertSelective")
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false,
            resultType = Integer.class)
    int insertSelective(TbFiledInfo record);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table
     * tb_filed_info
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbFiledInfoSqlProvider.class, method = "selectByExample")
    @Results({@Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true),
            @Result(column = "cert_config_id", property = "certConfigId",
                    jdbcType = JdbcType.INTEGER),
            @Result(column = "filed_serial", property = "filedSerial", jdbcType = JdbcType.VARCHAR),
            @Result(column = "filed_name", property = "filedName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "filed_name_zh", property = "filedNameZh",
                    jdbcType = JdbcType.VARCHAR),
            @Result(column = "filed_local", property = "filedLocal", jdbcType = JdbcType.VARCHAR),
            @Result(column = "show_enable", property = "showEnable", jdbcType = JdbcType.INTEGER),
            @Result(column = "filed_demo", property = "filedDemo", jdbcType = JdbcType.VARCHAR)})
    List<TbFiledInfo> selectByExample(TbFiledInfoExample example);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table
     * tb_filed_info
     *
     * @mbg.generated
     */
    @Select({"select",
            "id, cert_config_id, filed_serial, filed_name, filed_name_zh, filed_local, show_enable, ",
            "filed_demo", "from tb_filed_info", "where id = #{id,jdbcType=INTEGER}"})
    @Results({@Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true),
            @Result(column = "cert_config_id", property = "certConfigId",
                    jdbcType = JdbcType.INTEGER),
            @Result(column = "filed_serial", property = "filedSerial", jdbcType = JdbcType.VARCHAR),
            @Result(column = "filed_name", property = "filedName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "filed_name_zh", property = "filedNameZh",
                    jdbcType = JdbcType.VARCHAR),
            @Result(column = "filed_local", property = "filedLocal", jdbcType = JdbcType.VARCHAR),
            @Result(column = "show_enable", property = "showEnable", jdbcType = JdbcType.INTEGER),
            @Result(column = "filed_demo", property = "filedDemo", jdbcType = JdbcType.VARCHAR)})
    TbFiledInfo selectByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table
     * tb_filed_info
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbFiledInfoSqlProvider.class, method = "updateByExampleSelective")
    int updateByExampleSelective(@Param("record") TbFiledInfo record,
            @Param("example") TbFiledInfoExample example);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table
     * tb_filed_info
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbFiledInfoSqlProvider.class, method = "updateByExample")
    int updateByExample(@Param("record") TbFiledInfo record,
            @Param("example") TbFiledInfoExample example);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table
     * tb_filed_info
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbFiledInfoSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(TbFiledInfo record);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table
     * tb_filed_info
     *
     * @mbg.generated
     */
    @Update({"update tb_filed_info", "set cert_config_id = #{certConfigId,jdbcType=INTEGER},",
            "filed_serial = #{filedSerial,jdbcType=VARCHAR},",
            "filed_name = #{filedName,jdbcType=VARCHAR},",
            "filed_name_zh = #{filedNameZh,jdbcType=VARCHAR},",
            "filed_local = #{filedLocal,jdbcType=VARCHAR},",
            "show_enable = #{showEnable,jdbcType=INTEGER},",
            "filed_demo = #{filedDemo,jdbcType=VARCHAR}", "where id = #{id,jdbcType=INTEGER}"})
    int updateByPrimaryKey(TbFiledInfo record);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table
     * tb_filed_info
     *
     * @mbg.generated
     */
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    @Insert({"<script>", "insert into tb_filed_info (cert_config_id, ",
            "filed_serial, filed_name, ", "filed_name_zh, filed_local, ",
            "show_enable, filed_demo)",
            "values<foreach collection=\"list\" item=\"detail\" index=\"index\" separator=\",\">(#{detail.certConfigId,jdbcType=INTEGER}, ",
            "#{detail.filedSerial,jdbcType=VARCHAR}, #{detail.filedName,jdbcType=VARCHAR}, ",
            "#{detail.filedNameZh,jdbcType=VARCHAR}, #{detail.filedLocal,jdbcType=VARCHAR}, ",
            "#{detail.showEnable,jdbcType=INTEGER}, #{detail.filedDemo,jdbcType=VARCHAR})</foreach></script>"})
    int batchInsert(List<TbFiledInfo> list);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table
     * tb_filed_info
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbFiledInfoSqlProvider.class, method = "getOneByExample")
    @Results({@Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true),
            @Result(column = "cert_config_id", property = "certConfigId",
                    jdbcType = JdbcType.INTEGER),
            @Result(column = "filed_serial", property = "filedSerial", jdbcType = JdbcType.VARCHAR),
            @Result(column = "filed_name", property = "filedName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "filed_name_zh", property = "filedNameZh",
                    jdbcType = JdbcType.VARCHAR),
            @Result(column = "filed_local", property = "filedLocal", jdbcType = JdbcType.VARCHAR),
            @Result(column = "show_enable", property = "showEnable", jdbcType = JdbcType.INTEGER),
            @Result(column = "filed_demo", property = "filedDemo", jdbcType = JdbcType.VARCHAR)})
    Optional<TbFiledInfo> getOneByExample(TbFiledInfoExample example);
}
